package client;

import java.net.InetAddress;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;

import command.ICallback;
import command.IResponse;
import config.Configure;

import util.SimpleCondition;

public class GetUserTimelineCallback implements ICallback {
	List<String> tweets = null;
	SimpleCondition cond = new SimpleCondition();

	@Override
	public void init(List<InetAddress> addrs) {
	}

	@Override
	public void preprocess(IResponse res) {
		tweets = (List<String>) res.get();
		cond.signalAll();
	}

	@Override
	public Object get() {
		try {
			cond.await(Configure.getRpcTimeout(), TimeUnit.MICROSECONDS);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return tweets;
	}

}
